package com.asset.salesforce.converter;

import com.asset.salesforce.domain.Appointment;
import com.asset.salesforce.form.AppointmentForm;

public class AppointmentConverter {

	public AppointmentForm appointmentConvertor(Appointment appointment){
		AppointmentForm appointmentForm = new AppointmentForm();
		if(appointment.getSalesMan().getId()!=null){
			appointmentForm.setSalesMan(appointment.getSalesMan().getId());
		}
		if(appointment.getContactedPerson().getId()!=null){
			appointmentForm.setContactedPerson(appointment.getContactedPerson().getId());
		}
		
		if(appointment.getDay()!=null){
			appointmentForm.setDay(appointment.getDay());
		}
		if(appointment.getDate()!=null){
			String dateSubstring = appointment.getDate().toString().substring(0, 10);
			String[] dateSplit = dateSubstring.split("-");
			String dateFinal = dateSplit[2]+"/" +dateSplit[1]+"/" +dateSplit[0];
			appointmentForm.setDate(dateFinal);
		}

		
		if(appointment.getTime()!=null){
			appointmentForm.setTime(appointment.getTime());
		}
		if(appointment.getComment()!=null){
			appointmentForm.setComment(appointment.getComment());
		}
		if(appointment.getNextFollowUp()!=null){
			appointmentForm.setNextFollowUp(appointment.getNextFollowUp().toString());
		}
		if(appointment.getFollowUpType()!=null){
			appointmentForm.setNextFollowUpType(appointment.getFollowUpType());
		}
		if(appointment.getFollowUpDetails()!=null){
			appointmentForm.setNextFollowUpDetails(appointment.getFollowUpDetails());
		}

		if(appointment.getFollowUpDate()!=null){
			String followUpDateSubstring = appointment.getFollowUpDate().toString().substring(0, 10);
			String[] followUpDateSplit = followUpDateSubstring.split("-");
			String followUpDateFinal = followUpDateSplit[2]+"/" +followUpDateSplit[1]+"/" +followUpDateSplit[0];
			appointmentForm.setNextFollowUpDate(followUpDateFinal);
		}
		
		if(appointment.getMeetingDone()!=null){
			appointmentForm.setMeetingDone(appointment.getMeetingDone());
		}
		if(appointment.getMeetingDuration()!=null){
			appointmentForm.setMeetingDuration(appointment.getMeetingDuration());
		}
		if(appointment.getCustomerNeed()!=null){
			appointmentForm.setCustomerNeed(appointment.getCustomerNeed());
		}
		if(appointment.getDemoDone()!=null){
			appointmentForm.setDemoDone(appointment.getDemoDone());
		}
		if(appointment.getOfferSubmitted()!=null){
			appointmentForm.setOfferSubmitted(appointment.getOfferSubmitted());
		}
		if(appointment.getCompatitorOffer()!=null){
			appointmentForm.setCompetitorOffer(appointment.getCompatitorOffer());
		}
		if(appointment.getDealClosingDone()!=null){
			appointmentForm.setDealClosingDone(appointment.getDealClosingDone());
		}
		if(appointment.getDealClosingReason()!=null){
			appointmentForm.setDealClosingReason(appointment.getDealClosingReason());
		}
		if(appointment.getParentId()!=null){
			appointmentForm.setParentId(appointment.getParentId());
		}
		if(appointment.getParentType()!=null){
			appointmentForm.setParentType(appointment.getParentType());
		}
		if(appointment.getReplyPeriod()!=null){
			appointmentForm.setReplyPeriod(appointment.getReplyPeriod());
		}
		if(appointment.getConfirmationDateExpected()!=null){
			appointmentForm.setConfirmationDateExpected(appointment.getConfirmationDateExpected());
		}
		if(appointment.getDiscountDone()!=null){
			appointmentForm.setDiscountDone(appointment.getDiscountDone());
		}
		
		return appointmentForm;
	}
}
